<!doctype html public "-//W3C//DTD HTML 4.0 Frameset//EN""http://www.w3.org/TR/REC-html40/frameset.dtd">
<html>
<head>
<title>
 Overview
</title>
<link rel ="stylesheet" type="text/css" href="stylesheet.css" title="Style">
<script>
function asd() {
	
		parent.document.title="xslt.js Overview";
	
}
</script>
</head>
<body bgcolor="white" onload="asd();">

<!-- ========== START OF NAVBAR ========== -->
<a name="navbar_top"><!-- --></a>
<table border="0" width="100%" cellpadding="1" cellspacing="0">
<tr>
<td colspan=2 bgcolor="#EEEEFF" class="NavBarCell1">
<a name="navbar_top_firstrow"><!-- --></a>
<table border="0" cellpadding="0" cellspacing="3">
  <tr align="center" valign="top">
  
  
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="overview-summary.html"><font class="NavBarFont1"><b>Overview</b></font></a>&nbsp;</td>
  <td bgcolor="#FFFFFF" class="NavBarCell1Rev">	&nbsp;<font class="NavBarFont1Rev"><b>File</b></font>&nbsp;</td>
  

  <td bgcolor="#FFFFFF" class="NavBarCell1"> 	<font class="NavBarFont1">Class</font>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="overview-tree.html"><font class="NavBarFont1"><b>Tree</b></font></a>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="index-all.html"--><font class="NavBarFont1"><b>Index</b></font></a>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="help-doc.html"><font class="NavBarFont1"><b>Help</b></font></a>&nbsp;</td>
  </tr>
</table>
</td>
<td bgcolor="#EEEEFF" align="right" valign="top">
<em>
<b></b></em>
</td>
</tr>

<tr>
<td bgcolor="white" class="NavBarCell2"><font size="-2">
&nbsp;PREV&nbsp;
&nbsp;NEXT</font></td>
<td bgcolor="white" class="NavBarCell2"><font size="-2">
  <a href="index.html" target="_top"><b>FRAMES</b></a>  &nbsp;
&nbsp;<a href="overview-summary.html" target="_top"><b>NO FRAMES</b></a>
&nbsp;&nbsp;
<script>
  <!--
  if(window==top) {
    document.writeln('<A HREF="allclasses-noframe.html" TARGET=""><B>All Classes</B></A>');
  }
  //-->
</script>
<noscript>
<a href="allclasses-noframe.html" target=""><b>All Classes</b></a>
</noscript>
</font></td>
</tr>
</table>
<!-- =========== END OF NAVBAR =========== -->

<hr>
<center>
	
	   <h2>xslt.js</h2>
	
</center>

	


<h4>Summary</h4>
<p>
	
		No overview generated for 'xslt.js'<BR/><BR/>
	
</p>

<hr>


    <table border="1" cellpadding="3" cellspacing="0" width="100%">
    <tr bgcolor="#CCCCFF" class="TableHeadingColor">
    <td colspan=2><font size="+2">
    
        <b>Class Summary</b>
    
    </font></td>
    </tr>
    
    <tr bgcolor="white" class="TableRowColor">
    <td width="15%"><b><a href="Transformation.html">Transformation</a></b></td>
    <td>&nbsp;</td>
    </tr>
    
    </table>
    <hr/> 


<!-- ========== METHOD SUMMARY =========== -->

	<a name="method_summary"><!-- --></a>
	<table border="1" cellpadding="3" cellspacing="0" width="100%">
		<tr bgcolor="#CCCCFF" class="TableHeadingColor">
			<td colspan=2>
				<font size="+2">
					<b>Method Summary</b>
				</font>
			</td>
		</tr>
	
		
		   <tr bgcolor="white" class="TableRowColor">
		      <td align="right" valign="top" width="1%">
			 <font size="-1">
			    <code>static&nbsp;boolean</code>
			 </font>
		      </td>
		      <td>
			 <code>
			    <b>
			       <a href="GLOBALS.html#!s!browserSupportsXSLT">browserSupportsXSLT</a></b>()
			 </code>
			 <br>
			 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
			 Returns whether the browser supports XSLT.
		      </td>
		   </tr>
		
	
	</table>
    <p>

<!-- ========== END METHOD SUMMARY =========== -->


        <pre class="sourceview"><span class="comment">/*
 * xslt.js
 *
 * Copyright (c) 2005-2008 Johann Burkard (&lt;mailto:jb<span class="attrib">@eaio</span>.com&gt;)
 * &lt;http://eaio.com&gt;
 * 
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 * 
 * The above copyright notice and this permission notice shall be included
 * in all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
 * NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
 * USE OR OTHER DEALINGS IN THE SOFTWARE.
 * 
 */</span>

<span class="comment">/**
 * Constructor for client-side XSLT transformations.
 * 
 * <span class="attrib">@author</span> &lt;a href="mailto:jb<span class="attrib">@eaio</span>.com"&gt;Johann Burkard&lt;/a&gt;
 * <span class="attrib">@version</span> $Id: xslt.js,v 1.7 2008/08/29 21:22:55 Johann Exp $
 * <span class="attrib">@constructor</span>
 */</span>
<span class="reserved">function</span> Transformation() {

    var xml;
    
    var xmlDoc;
    
    var xslt;
    
    var xsltDoc;

    var callback = <span class="reserved">function</span>() {};
    
    <span class="comment">/**
     * Sort of like a fix for Opera who doesn't always get readyStates right.
     */</span>
    var transformed = false;
        
    <span class="comment">/**
     * Returns the URL of the XML document.
     * 
     * <span class="attrib">@return</span> the URL of the XML document
     * <span class="attrib">@type</span> String
     */</span>
    <span class="reserved">this</span>.getXml = <span class="reserved">function</span>() {
        <span class="reserved">return</span> xml;
    }
    
    <span class="comment">/**
     * Returns the XML document.
     * 
     * <span class="attrib">@return</span> the XML document
     */</span>
    <span class="reserved">this</span>.getXmlDocument = <span class="reserved">function</span>() {
        <span class="reserved">return</span> xmlDoc
    }
    
    <span class="comment">/**
     * Sets the URL of the XML document.
     * 
     * <span class="attrib">@param</span> x the URL of the XML document
     * <span class="attrib">@return</span> this
     * <span class="attrib">@type</span> Transformation
     */</span>
    <span class="reserved">this</span>.setXml = <span class="reserved">function</span>(x) {
        xml = x;
        <span class="reserved">return</span> <span class="reserved">this</span>;
    }
    
    <span class="comment">/**
     * Returns the URL of the XSLT document.
     * 
     * <span class="attrib">@return</span> the URL of the XSLT document
     * <span class="attrib">@type</span> String
     */</span>
    <span class="reserved">this</span>.getXslt = <span class="reserved">function</span>() {
        <span class="reserved">return</span> xslt;
    }
    
    <span class="comment">/**
     * Returns the XSLT document.
     * 
     * <span class="attrib">@return</span> the XSLT document
     */</span>
    <span class="reserved">this</span>.getXsltDocument = <span class="reserved">function</span>() {
        <span class="reserved">return</span> xsltDoc;
    }
    
    <span class="comment">/**
     * Sets the URL of the XSLT document.
     * 
     * <span class="attrib">@param</span> x the URL of the XML document
     * <span class="attrib">@return</span> this
     * <span class="attrib">@type</span> Transformation
     */</span>
    <span class="reserved">this</span>.setXslt = <span class="reserved">function</span>(x) {
        xslt = x;
        <span class="reserved">return</span> <span class="reserved">this</span>;
    }
    
    <span class="comment">/**
     * Returns the callback function.
     * 
     * <span class="attrib">@return</span> the callback function
     */</span>
    <span class="reserved">this</span>.getCallback = <span class="reserved">function</span>() {
        <span class="reserved">return</span> callback;
    }
    
    <span class="comment">/**
     * Sets the callback function
     * 
     * <span class="attrib">@param</span> c the callback function
     * <span class="attrib">@return</span> this
     * <span class="attrib">@type</span> Transformation
     */</span>
    <span class="reserved">this</span>.setCallback = <span class="reserved">function</span>(c) {
        callback = c;
        <span class="reserved">return</span> <span class="reserved">this</span>;
    }
    
    <span class="comment">/**
     * Sets the target element to write the transformed content to and &lt;em&gt;asynchronously&lt;/em&gt;
     * starts the transformation process.
     * &lt;p&gt;
     * &lt;code&gt;target&lt;/code&gt; is the ID of an element. 2DO
     * &lt;p&gt;
     * This method may only be called after {<span class="attrib">@link</span> #setXml} and {<span class="attrib">@link</span> #setXslt} have
     * been called.
     * &lt;p&gt;
     * Note that the target element must exist once this method is called. Calling
     * this method before &lt;code&gt;onload&lt;/code&gt; was fired will most likely
     * not work.
     * 
     * <span class="attrib">@param</span> target the ID of an element
     */</span>
    <span class="reserved">this</span>.transform = <span class="reserved">function</span>(target) {
        <span class="reserved">if</span> (!browserSupportsXSLT()) {
           <span class="reserved">return</span>;
        }
        var str = /^\s*&lt;/;
        var t = <span class="reserved">this</span>;
        <span class="reserved">if</span> (document.recalc) {
            var change = <span class="reserved">function</span>() {
                var c = <span class="literal">'complete'</span>;
                <span class="reserved">if</span> (xm.readyState == c &amp;&amp; xs.readyState == c) {
                    window.setTimeout(<span class="reserved">function</span>() {
                        xmlDoc = xm.XMLDocument;
                        xsltDoc = xs.XMLDocument;
                        callback(t);
                        document.all[target].innerHTML = xm.transformNode(xs.XMLDocument);
                    }, 50);
                }
            };
            
            var xm = document.createElement(<span class="literal">'xml'</span>);
            xm.onreadystatechange = change;
            xm[str.test(xml) ? <span class="literal">"innerHTML"</span> : <span class="literal">"src"</span>] = xml;
            
            var xs = document.createElement(<span class="literal">'xml'</span>);
            xs.onreadystatechange = change;
            xs[str.test(xslt) ? <span class="literal">"innerHTML"</span> : <span class="literal">"src"</span>] = xslt;
            
            with (document.body) {
                insertBefore(xm);
                insertBefore(xs);
            };
        }
        <span class="reserved">else</span> {
            var transformed = false;

            var xm = {
                readyState: 4
            };
            var xs = {
                readyState: 4
            };
            var change = <span class="reserved">function</span>() {
                <span class="reserved">if</span> (xm.readyState == 4 &amp;&amp; xs.readyState == 4 &amp;&amp; !transformed) {
                    xmlDoc = xm.responseXML;
                    xsltDoc = xs.responseXML;
                    var resultDoc;
                    var processor = new XSLTProcessor();
                                       
                    <span class="reserved">if</span> (typeof processor.transformDocument == <span class="literal">'function'</span>) {
                        <span class="comment">// obsolete Mozilla interface</span>
                        resultDoc = document.implementation.createDocument(<span class="literal">""</span>, <span class="literal">""</span>, null);
                        processor.transformDocument(xm.responseXML, xs.responseXML, resultDoc, null);
                        var out = new XMLSerializer().serializeToString(resultDoc);
                        callback(t);
                        document.getElementById(target).innerHTML = out;
                    }
                    <span class="reserved">else</span> {
                        processor.importStylesheet(xs.responseXML);
                        resultDoc = processor.transformToFragment(xm.responseXML, document);
                        callback(t);
                        document.getElementById(target).innerHTML = <span class="literal">''</span>;
                        document.getElementById(target).appendChild(resultDoc);
                    }
                    
                    transformed = true;
                }
            };

            <span class="reserved">if</span> (str.test(xml)) {
                xm.responseXML = new DOMParser().parseFromString(xml, <span class="literal">"text/xml"</span>);
            }
            <span class="reserved">else</span> {
                xm = new XMLHttpRequest();
                xm.onreadystatechange = change;
                xm.open(<span class="literal">"GET"</span>, xml);
                xm.send(null);
            }

            <span class="reserved">if</span> (str.test(xslt)) {
                xs.responseXML = new DOMParser().parseFromString(xslt, <span class="literal">"text/xml"</span>);
                change();
            }
            <span class="reserved">else</span> {
                xs = new XMLHttpRequest();
                xs.onreadystatechange = change;
                xs.open(<span class="literal">"GET"</span>, xslt);
                xs.send(null);
            }
        }
    }

}

<span class="comment">/**
 * Returns whether the browser supports XSLT.
 * 
 * <span class="attrib">@return</span> the browser supports XSLT
 * <span class="attrib">@type</span> boolean
 */</span>
<span class="reserved">function</span> browserSupportsXSLT() {
    var support = false;
    <span class="reserved">if</span> (document.recalc) { <span class="comment">// IE 5+</span>
        support = true;
    }
    <span class="reserved">else</span> <span class="reserved">if</span> (window.XMLHttpRequest != undefined &amp;&amp; window.XSLTProcessor != undefined) { <span class="comment">// Mozilla 0.9.4+, Opera 9+</span>
       var processor = new XSLTProcessor();
       <span class="reserved">if</span> (typeof processor.transformDocument == <span class="literal">'function'</span>) {
           support = window.XMLSerializer != undefined;
       }
       <span class="reserved">else</span> {
           support = true;
       }
    }
    <span class="reserved">return</span> support;
}
</pre>
	<hr>



<!-- ========== START OF NAVBAR ========== -->
<a name="navbar_top"><!-- --></a>
<table border="0" width="100%" cellpadding="1" cellspacing="0">
<tr>
<td colspan=2 bgcolor="#EEEEFF" class="NavBarCell1">
<a name="navbar_top_firstrow"><!-- --></a>
<table border="0" cellpadding="0" cellspacing="3">
  <tr align="center" valign="top">
  
  
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="overview-summary.html"><font class="NavBarFont1"><b>Overview</b></font></a>&nbsp;</td>
  <td bgcolor="#FFFFFF" class="NavBarCell1Rev">	&nbsp;<font class="NavBarFont1Rev"><b>File</b></font>&nbsp;</td>
  

  <td bgcolor="#FFFFFF" class="NavBarCell1"> <font class="NavBarFont1">Class</font>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="overview-tree.html"><font class="NavBarFont1"><b>Tree</b></font></a>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="index-all.html"--><font class="NavBarFont1"><b>Index</b></font></a>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="help-doc.html"><font class="NavBarFont1"><b>Help</b></font></a>&nbsp;</td>
  </tr>
</table>
</td>
<td bgcolor="#EEEEFF" align="right" valign="top"><em>
<b></b></em>
</td>
</tr>

<tr>
<td bgcolor="white" class="NavBarCell2"><font size="-2">
&nbsp;PREV&nbsp;
&nbsp;NEXT</font></td>
<td bgcolor="white" class="NavBarCell2"><font size="-2">
  <a href="index.html" target="_top"><b>FRAMES</b></a>  &nbsp;
&nbsp;<a href="overview-summary.html" target="_top"><b>NO FRAMES</b></a>
&nbsp;&nbsp;
<script>
  <!--
  if(window==top) {
    document.writeln('<A HREF="allclasses-noframe.html" TARGET=""><B>All Classes</B></A>');
  }
  //-->
</script>
<noscript>
<a href="allclasses-noframe.html" target=""><b>All Classes</b></a>
</noscript>
</font></td>
</tr>
</table>
<!-- =========== END OF NAVBAR =========== -->

<hr>
<font size="-1">

</font>
<div class="jsdoc_ctime">Documentation generated by <a href="http://jsdoc.sourceforge.net/" target="_parent">JSDoc</a> on Fri Aug 29 23:41:18 2008</div>
</body>
</html>
